package com.webSite.demo.cy.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.webSite.demo.cy.bean.HomeIndex;
import com.webSite.demo.cy.mapper.HomeIndexMapper;

@Controller
@EnableAutoConfiguration
public class HomeIndexController {
	
	@Autowired
	HomeIndexMapper homeIndexMapper;
	
	
	//home页面显示(已完成)
	@RequestMapping("/home.html")  
    String home(Model model) {
		HomeIndex index = homeIndexMapper.findLimitOne();
		model.addAttribute("home", index);
        return "admin/home";  
    }
	
	//home添加(已完成)
	@RequestMapping("/updateOrInsertHome.html")  
    String insertHome(HomeIndex home) {
		home.setCreated(new Date());
		home.setUpdated(new Date());
		homeIndexMapper.insertHome(home);
        return "redirect:/home.html";
    }
}
